<template>
	<view class="content" v-if="show==1">
		<image class="beijing" :src="site.b" mode="widthFix"></image>
		<view class="hongbao">
			<image class="hb" :src="site.hb" mode="widthFix"></image>
			<view class="hb2">邀请<text>1位新用户</text>可得</view>
			<view class="hb3"><text>￥</text>{{site.yhq_money}}</view>
			<view class="hb4">好友可得{{site.yhq_money2}}元红包</view>
			<view class="hb5">购买课程下单时可进行抵扣</view>
			<!-- #ifdef MP-WEIXIN -->
			<button class="hb6" type="default" open-type="share" plain="true" ></button>
			<!-- #endif -->
			<!-- #ifdef APP-PLUS -->
			<view class="hb6" @click="fx"></view>
			<!-- #endif -->
			<view class="hb7" @click="erweima"></view>
		</view>
		<view class="tishi">
			<view class="tishi2">活动规则</view>
			<view class="tishi3">
				<text>{{site.guize}}</text>
			</view>
		</view>
		<view class="tishi">
			<view class="tishi2">邀请成功</view>
			<view class="tishi4">
				<view class="tishi5" v-for="u in user">
					<image :src="u.avatar" mode="aspectFit"></image>
					<view class="tishi5-1">
						<view class="tishi5-1-1">{{u.nickname}}</view>
						<view class="tishi5-1-2">{{u.createtime}}</view>
					</view>
					<view class="tishi5-2">￥{{u.yq_money}}</view>
				</view>
				<view class="meiyou" v-if="!user[0]">暂无数据，快去邀请好友吧</view>
			</view>
		</view>
		<view class="tanceng" @click="erweima" v-if="is_m==true"></view>
		<image class="erweima" @click="erweima" v-if="is_m==true" :src="site.erweima" mode="widthFix"></image>
	</view>
</template>

<script>
	var app=getApp();
	export default {
		data() {
			return {
				uid:0,
				show:0,
				is_m:false,
				user:[],
				site:[]
			}
		},
		onLoad() {
			const uid = uni.getStorageSync('uid');
			if(app.isBlank(uid)==true){
				app.error_msg("请先登录");
			}
			this.uid=uid;
			this.getdata();
		},
		methods: {
			getdata(){
				var that=this;
				uni.showLoading({
				    title: '数据加载中'
				});
				uni.request({
				    url: app.globalData.url+"user/yaoqing",
					method:"POST",
					dataType:"json",
					header: {
					    'content-type': 'application/x-www-form-urlencoded'
					},
				    data: {uid:that.uid},
				    success: (res) => {
						uni.hideLoading();
						if(res.data.code!=1){
							app.error_msg(res.data.msg);
						}
						that.site=res.data.data.site
						that.user=res.data.data.user
						that.show=1;
				    }
				});
			},
			erweima(){
				this.is_m=!this.is_m;
			},
			fx(){
				var that=this;
				uni.share({
				    provider: 'weixin',
				    scene: "WXSceneSession",
				    type: 5,
				    imageUrl: that.site.fx_img,
				    title: that.site.fx_title,
				    miniProgram: {
				        id: 'gh_e35b785da324',
				        path: 'pages/user/byao?uid='+that.uid,
				        type: 0,
				        webUrl: 'https://www.bjfen.com'
				    },
				    success: ret => {
				        console.log(JSON.stringify(ret));
				    }
				});
			},
			onShareAppMessage(res) {
				var that=this;
			    return {
			      title: that.site.fx_title,
				  imageUrl:that.site.fx_img,
			      path: '/pages/user/byao?uid='+that.uid
			    }
			}
		}
	}
</script>

<style>
	.erweima{width:200px;position: fixed;top:50%;margin-top: -100px;left:50%;margin-left: -100px;z-index: 9999;}
	.tanceng{width:100%;height:100vh;position: fixed;top:0px;background-color: #000000;opacity: 0.7;z-index: 9999;}
	.meiyou{width:100%;text-align: center;margin: 40px 0px;color:#999;}
	.tishi5-2{width:30px;height:50px;line-height: 50px;color:#fa1d2c;font-size: 1rem;text-align: right;}
	.tishi5-1-2{width:100%;height:20px;line-height:16px;overflow: hidden;color:#999;}
	.tishi5-1-1{width:100%;height:30px;line-height:32px;font-size: 0.95rem;overflow: hidden;}
	.tishi5-1{width:100%;flex: 1;}
	.tishi5 image{width:50px;height:50px;border-radius: 50%;margin-right: 8px;}
	.tishi5{width:100%;height:50px;display: flex;padding: 10px 0px;}
	.tishi4{width:94%;padding: 0 3%;}
	.tishi3{padding: 10px;line-height: 25px;color:#666;}
	.tishi2{width:100%;height:40px;line-height: 40px;text-align: center;color:#fff;background-color: #fe4b23;}
	.tishi{width:94%;margin: 10px 3%;background-color: #fff;border-radius: 5px;overflow: hidden;z-index: 9999;}
	.hb7{width:40%;height:25px;position: absolute;bottom: 3.5%;left:50%;margin-left: -20%;}
	.hb6{width:75%;height:50px;position: absolute;bottom: 13%;left:50%;margin-left: -37%;border:0px!important;}
	.hb5{width:100%;position: absolute;top:63%;text-align: center;color:#fef8de;}
	.hb4{width:100%;position: absolute;top:43%;text-align: center;font-size: 1rem;color:#fa1d2c;font-weight: 600;}
	.hb3 text{font-size:1.9rem!important;}
	.hb3{width:100%;position: absolute;top:10%;text-align: center;font-size: 4.5rem;color:#fa1d2c;font-weight: 600;}
	.hb2 text{color:#fe2f2f!important;letter-spacing:1px!important;}
	.hb2{width:100%;position: absolute;top:15px;text-align: center;font-size: 0.95rem;color:#b7591b;letter-spacing:3px;font-weight: 600;}
	.hb{width:90%;}
	.hongbao{width:100%;text-align: center;margin-top: 30px;position: relative;z-index: 9999;}
	.beijing{width:100%;position: fixed;top:0px;}
	page{background-color: #fadfaa;}
</style>
